package com.zhdl.modules.demo.hardware_connect;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class LinkDevice {
    private String name;
    private String port;
    private long lastMsgTime;
    private long onlineInterval = 10000;
    private boolean online;
    private String lastMsg;
    public LinkDevice(String name, String port) {
        this.name = name;
        this.port = port;
    }

    public LinkDevice(String name, String port, long lastMsgTime, long onlineInterval) {
        this.name = name;
        this.port = port;
        this.lastMsgTime = lastMsgTime;
        this.onlineInterval = onlineInterval;
    }
    public void checkOnline(){
        online = System.currentTimeMillis() - lastMsgTime <= onlineInterval;
    }
}
